package tmt.usercenter.web.plugin.filesevice;

import com.tmt.datatable.editor.IFileDataHolder;
import com.tmt.fileservice.IFileDataResolver;
import lombok.Data;

import java.io.File;
import java.io.IOException;

/**
 * Created by ThreeManTeam on 2017/5/26.
 */
@Data
public class FileDataResolver implements IFileDataResolver {

    private IFileDataHolder holder;

    public FileDataResolver(IFileDataHolder holder){
        this.holder = holder;
    }

    @Override
    public String getFileType() {
        return holder.getFileName().split("\\.")[1];
    }

    @Override
    public Long getFileLength() {
        return holder.getFileLength();
    }

    @Override
    public void transferTo(File file) throws IOException {
        holder.transferTo(file);
    }
}
